#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
@author:shengwei
@file:subprocess_py.py
@time:2018/2/23 002316:42
"""
import subprocess

print('$ nslookup')
p = subprocess.Popen(['nslookup'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = p.communicate(b'set q=mx\npython.org\nexit\n')
print(output)
print('Exit code:', p.returncode)
